﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;


using CRM.Entity;
using CRM.Entity.Extra;
using CRM.DataService;
using CRM.Entity.Page;
using CRM.Controller.Validation;

namespace CRM.Controller
{
    public partial class News_Type_Controller
    {
        //对数据层的服务类
        News_Type_DataService dataService;

        public News_Type_Controller()
        {
            dataService = new News_Type_DataService();
        }

        public List<News_Type> GetAll()
        {
            return dataService.GetAll();
        }

        public News_TypePage GetList(PageInfo page)
        {
            return dataService.GetList(page);
        }

        public News_TypePage GetList(Func<News_Type, bool> func)
        {
            return dataService.GetList(func);
        }

        public News_TypePage GetList(PageInfo page, Func<News_Type, bool> func)
        {
            return dataService.GetList(page, func);
        }

        public List<News_Type> GetListTop(int top, Func<News_Type, bool> func)
        {
            return dataService.GetListTop(top, func);
        }

        public News_Type GetSingle(int news_TypeID)
        {
            return dataService.GetSingle(news_TypeID);
        }

        public News_Type GetSingleMultiple(Func<News_Type, bool> func)
        {
            return dataService.GetSingleMultiple(func);
        }

        public bool Add(News_Type news_Type)
        {               
            //先对字段的输入验证
            if (!InputValidation.CheckNews_Type(news_Type))
                return false;
                
            bool isSuccess = dataService.Add(news_Type);

            return isSuccess;
        }
        
        public bool AddBatch(List<News_Type> list)
        {    
            //先对字段的输入验证
            foreach(var item in list)
            {
                if (!InputValidation.CheckNews_Type(item))
                return false;
            }
            
            bool isSuccess = dataService.AddBatch(list);

            return isSuccess;
        }

        public bool Update(News_Type news_Type)
        {
            //先对字段的输入验证
            if (!InputValidation.CheckNews_Type(news_Type))
                return false;
               
            bool isSuccess = dataService.Update(news_Type);

            return isSuccess;
        }
        
        public bool UpdateBatch(List<News_Type> list)
        {
            //先对字段的输入验证
            foreach(var item in list)
            {
                if (!InputValidation.CheckNews_Type(item))
                return false;
            }
            
            bool isSuccess = dataService.UpdateBatch(list);

            return isSuccess;
        }

        public bool Delete(News_Type news_Type)
        {
            //先对字段的输入验证
            if (!InputValidation.CheckNews_Type(news_Type))
                return false;
           
            bool isSuccess = dataService.Delete(news_Type);

            return isSuccess;
        }
    }
}





